package org.mozhu.rpc.transport;

import org.mozhu.rpc.transport.channel.JChannelGroup;
import org.mozhu.rpc.transport.processor.ConsumerProcessor;

import java.util.Collection;

public interface JConnector<C> {
    /**
     * Returns the rpc processor.
     */
    ConsumerProcessor processor();

    /**
     * Binds the rpc processor.
     */
    void withProcessor(ConsumerProcessor processor);

    /**
     * Connects to the remote peer.
     */
    C connect(UnresolvedAddress address);

    /**
     * Connects to the remote peer.
     */
    C connect(UnresolvedAddress address, boolean async);

    /**
     * Returns or new a {@link JChannelGroup}.
     */
    JChannelGroup group(UnresolvedAddress address);

    /**
     * Returns all {@link JChannelGroup}s.
     */
    Collection<JChannelGroup> groups();

    /**
     * Shutdown the server.
     */
    void shutdownGracefully();
}
